package cn.wbnyua.msm.web.api;

import cn.wbnyua.msm.util.JsonResponse;
import cn.wbnyua.msm.web.domain.Staff;
import cn.wbnyua.msm.web.domain.Supplier;
import cn.wbnyua.msm.web.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 作者：wbnyua.
 * 创建时间: 2023/2/8 22:59.
 */
@RestController
@RequestMapping("/api/supplier")
public class SupplierApi {

    @Autowired
    private SupplierService service;

    @GetMapping
    public JsonResponse<List<Supplier>> list(){
        return new JsonResponse<>(service.findAll());
    }

    @PostMapping
    public JsonResponse<String> add(Supplier supplier){
        service.add(supplier);
        return JsonResponse.success();
    }

    @PutMapping
    public JsonResponse<String> update(Supplier supplier){
        service.update(supplier);
        return JsonResponse.success();
    }


    @DeleteMapping
    public JsonResponse<String> remove(Long id){
        service.remove(id);
        return JsonResponse.success();
    }

}
